package base.utils;
/**
 * 页面元素
 * @author Kouyq
 *
 */
public class PageElement {
	
	private String pgTitle;
	private String inpage = "center.jsp";//默认页面
	private Table table;
	private String activeMenu;
	
	public String getPgTitle() {
		return pgTitle;
	}

	/**
	 * 页面标题
	 * @param pgTitle
	 */
	public PageElement setPgTitle(String pgTitle) {
		this.pgTitle = pgTitle;
		return this;
	}

	public String getInpage() {
		return inpage;
	}

	/**
	 * 主显示区域载入的页面
	 * @param inpage
	 */
	public PageElement setInpage(String inpage) {
		if (inpage == null) {
            throw new RuntimeException("Value for inpage cannot be null");
        }
		this.inpage = inpage;
		return this;
	}
	
	/**
	 * 表格
	 * @author Kouyq
	 */
	public class Table{
		
		String tbTitle;
		String domjs;
		boolean add = false;
		String addTitle;//添加项的标题
		String addURL;//添加请求的路径
		
		Table(){
			super();
			/*添加默认属性*/
			setDomjs("dome");
			setTbTitle("表格例子");
			setInpage("dataTable.jsp");
		}
		
		/**
		 * 表格标题
		 * @param tbTitle
		 */
		public Table setTbTitle(String tbTitle) {
			this.tbTitle = tbTitle;
			return this;
		}

		/**
		 * 取值的js
		 * @param domjs
		 */
		public Table setDomjs(String domjs) {
			if (domjs == null) {
	            throw new RuntimeException("Value for domjs cannot be null");
	        }
			this.domjs = domjs;
			return this;
		}

		/**
		 * 是否可以添加项
		 */
		public Table canAdd(String addTitle, String addURL) {
			if (addTitle == null) {
	            throw new RuntimeException("Value for addTitle cannot be null");
	        }
			if (addURL == null) {
	            throw new RuntimeException("Value for addURL cannot be null");
	        }
			this.add = true;
			this.addTitle = addTitle;
			this.addURL = addURL;
			return this;
		}

		public String getAddTitle() {
			return addTitle;
		}

		public String getAddURL() {
			return addURL;
		}

		public String getTbTitle() {
			return tbTitle;
		}

		public String getDomjs() {
			return domjs;
		}

		public boolean isAdd() {
			return add;
		}
	}

	public Table getTable() {
		return table;
	}

	/**
	 * 添加表格属性
	 */
	public Table setTable() {
		this.table = new Table();
		return this.table;
	}
	
	/**
	 * 添加表格自定义属性
	 * @param tbTitle 表格标题
	 * @param domjs 表格js
	 */
	public PageElement setTable(String tbTitle, String domjs) {
		this.table = new Table();
		table.setTbTitle(tbTitle).setDomjs(domjs);
		return this;
	}

	public String getActiveMenu() {
		return activeMenu;
	}

	/**
	 * 设置活动的菜单的URI
	 * @param activeMenu
	 */
	public PageElement setActiveMenu(String activeMenu) {
		this.activeMenu = activeMenu;
		return this;
	}
	
}
